package com.weijianhuawen.wjblog.web.controller;

import com.weijianhuawen.wjblog.common.aspect.ApiOperationLog;
import com.weijianhuawen.wjblog.common.utils.PageResponse;
import com.weijianhuawen.wjblog.common.utils.Response;
import com.weijianhuawen.wjblog.web.mode.vo.article.FindArticleDetailReqVo;
import com.weijianhuawen.wjblog.web.mode.vo.article.FindIndexArticlePageListReqVo;
import com.weijianhuawen.wjblog.web.service.ArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description:
 * @date: 2024-10-28 22:28
 */

@RestController
@RequestMapping("/article")
@Api(tags = "博客系统 文章模块")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    @PostMapping("/list")
    @ApiOperation(value = "获取文章首页文章数据")
    @ApiOperationLog(description = "获取首页相关文章信息")
    public PageResponse findArticlePageList(@RequestBody @Validated FindIndexArticlePageListReqVo vo) {
        return articleService.findIndexArticlePageList(vo);
    }

    @PostMapping("/detail")
    @ApiOperation(value = "获取文章详情")
    @ApiOperationLog(description = "根据文章id获取文章详情")
    public Response findArticleDetail(@RequestBody @Validated FindArticleDetailReqVo vo) {
        return articleService.findArticleDetailForHTML(vo);
    }
}
